package com.example.weiji_1;

import java.util.ArrayList;

import org.w3c.dom.Text;


import wordroid.model.TextList;
import wordroid.model.Texts;
import wordroid.model.Unit;
import wordroid.model.UnitList;
import wordroid.model.Units;

import com.example.weiji_1.datebase.DataAccess;
import com.example.weiji_1.datebase.SqlHelper;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;



public class Study1 extends Activity {

	private TextView view_2;
	private TextView view_4;
	private TextView view_5;
	private ArrayList<Units> texts;
	private ArrayList<UnitList> text1;
	private ArrayList<TextList> textlist;
	String[] text_1  ;
	int k = 1 ;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.study11);
		Button bt1 = (Button)this.findViewById(R.id.button1);
		Button bt2 = (Button)this.findViewById(R.id.button2);
		Button bt3 = (Button)this.findViewById(R.id.button3);
		view_2 = (TextView)this.findViewById(R.id.textView2);
		view_4 = (TextView)this.findViewById(R.id.textView4);
		view_5 = (TextView)this.findViewById(R.id.textView5);
		
		DataAccess data = new DataAccess(this);
		texts = data.Unit(null, null);
		textlist = data.QueryText(null, null);
		//Log.i("size", String.valueOf(bookList.size()));
		text_1 = new String[texts.size()];
		int i=0;
		for (;i<texts.size();i++){
			text_1[i]=texts.get(i).getinclude();
		}
			

       this.view_2.setText(text_1[0]); 
       //this.view_5.setText(textlist.get(1).getallnum());
       //this.view_4.setText(textlist.get(1).getlearned());
        //Log.i("study1","执锟叫碉拷锟斤拷锟斤拷锟斤拷");
       
	
		
		bt1.setOnClickListener(new View.OnClickListener() {
			

			@Override
			public void onClick(View arg0) {
				//Toast.makeText(getApplicationContext(), "NEXT", 0).show();
				//i--;
				k--;
				if(k==0)
				{
					Dialog dialog = new AlertDialog.Builder(Study1.this)
		            .setIcon(R.drawable.dialog_icon)
		            .setTitle("鎻愰啋")
		            .setMessage("褰撳墠涓虹涓�瘝鏉★紝璇峰線涓嬪涔狅紒")
		            .setNegativeButton("纭畾", new DialogInterface.OnClickListener() {
		                public void onClick(DialogInterface dialog, int whichButton) {
		                   }
		            }).create();
					dialog.show();
					k++;
					view_5.setText(k);
				}
				view_2.setText(text_1[k]); 
				//view_4.setText(k);
				
			
				
			}
		});
		bt2.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				k++;
				view_2.setText(text_1[k]);
				//view_4.setText(k);
				
			}
		});
		bt3.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
			Toast.makeText(getBaseContext(), "宸叉爣璁板唴瀹�", 0).show();
				
			}
		});
}

}
